In an image encoding technique such as MPEG-2 and MPEG-4, an encoding is performed by dividing an input picture into macroblocks of 16×16 pixels, the macroblock (hereinafter referred to as “MB”) being a basic processing unit. As the encoding performed on the MB basis, a prediction, a transformation, a quantization, and an entropy encoding are well known. Among them, the quantization related to the present invention is performed on each coefficient of an input block based on an arbitrary quantization step size. When setting the quantization step size as Qstep, the input coefficient as C, and the quantization result as Z, an arithmetic expression of a general quantization is represented by Eq. 1 as follows:Z=round(C/Qstep)  Eq. 1
A compression ratio is improved by increasing the quantization step size Qstep. In this case, however, loss of information is increased. The influence of the information loss on image quality degradation depends on the pattern of the MB of interest. Specifically, in a region with a simple pattern such as sky and wall or a region with less motion, it is easy to perceive the image quality degradation. On the other hand, in a region with a complex pattern or a region with intense motion, it is difficult to perceive the image quality degradation. By using such visual characteristics, subjective image quality can be improved by setting a larger quantization step size in the region where it is difficult to perceive the image quality degradation, and conversely setting a smaller quantization step size in the region where it is easy to perceive the image quality degradation (see Patent Document 1 to Patent Document 3)
A conventional control of the quantization step size will be described with reference to FIG. 1. FIG. 1 shows a processing block diagram of a conventional encoding device. Reference numeral “100” denotes an encoding device. Reference numeral “101” denotes a MB division unit. Reference numeral “102” denotes a degradation cost evaluation unit. Reference numeral “103” denotes a quantization step size determination unit. Reference numeral “104” denotes a prediction unit. Reference numeral “105” denotes a transformation unit. Reference numeral “106” denotes a quantization unit. Reference numeral “107” denotes an entropy encoding unit. Reference numeral “108” denotes an inverse quantization unit. Reference numeral “109” denotes an inverse transformation unit. Reference numeral “110” denotes a reconstruction unit.
In FIG. 1, first, the encoding device 100 inputs an input image to the MB division unit 101. The MB division unit 101 divides the input image into blocks (MB) of 16×16 pixels, the block being called a macroblock (MB), and outputs the MBs to the degradation cost evaluation unit 102 and the prediction unit 104. The degradation cost evaluation unit 102 calculates the image quality degradation cost of each of the input MBs, and outputs it to the quantization step size determination unit 103. For example, when a variation in pixel values is defined as the image quality degradation cost, the degradation cost evaluation unit 102 calculates the image quality degradation cost by using the following Eq. 2 and Eq. 3:
                    DC        =                  round          ⁡                      (                                          (                                                      ∑                                          y                      =                      0                                        15                                    ⁢                                                                          ⁢                                                            ∑                                              x                        =                        0                                            15                                        ⁢                                                                                  ⁢                                          MB                      ⁡                                              [                                                  x                          ,                          y                                                ]                                                                                            )                            /              256                        )                                              Eq        .                                  ⁢        2            
                              COST          =                                    ∑                              y                =                0                            15                        ⁢                                                  ⁢                                          ∑                                  x                  =                  0                                15                            ⁢                                                          ⁢                              abs                ⁡                                  (                                      DC                    -                                          MB                      ⁡                                              [                                                  x                          ,                          y                                                ]                                                                              )                                                                    ,                            Eq        .                                  ⁢        3            
where DC represents an average pixel value in the MB, and COST is the sum of absolute values of differences between the DC and the pixel values and is the image quality degradation cost in this example.
First, the quantization step size determination unit 103 determines a reference quantization step size according to a target bit rate that is inputted from the outside. Subsequently, a quantization step size, which makes the image quality uniform, is obtained based on the image quality degradation cost inputted from the degradation cost evaluation unit 102. In order to determine the quantization step size based on the input image quality degradation cost, for example, a table 10 as shown in FIG. 10 is prepared. In the table 10, Qstep indicates the reference quantization step size. The quantization step size determination unit 103 outputs the determined quantization step size to the quantization unit 106. Further, the quantization step size is set for each MB.
The prediction unit 104 generates a prediction image by using the correlation with neighboring pixels of the MB or the correlation between the current frame and frames before and after the current frame, and outputs a differential image between the prediction image and the MB to the transformation unit 105. The transformation unit 105 transforms the input differential image into 4×4 blocks or 8×8 blocks by using orthogonal transformation such as two-dimensional discrete cosine transform (DCT), and outputs them to the quantization unit 106. The quantization unit 106 quantizes an input transform coefficients based on the quantization step size inputted from the quantization step size determination unit 103, and outputs the quantized transform coefficients to the entropy encoding unit 107 and the inverse quantization unit 108.
The entropy encoding unit 107 transforms encoded control information such as the input quantized transform coefficients and the quantization step size into a bit stream. Further, the entropy encoding unit 107 outputs the amount of codes generated when the information is transformed into the bit stream (generated code amount) to the quantization step size determination unit 103. The quantization step size determination unit 103 monitors whether the generated code amount is equal to a target bit rate and controls to make the generated code amount equal to the target bit rate by finely adjusting the reference quantization step size if the generated code amount is not equal to the target bit rate. Further, a reconstructed image is generated from the quantized transform coefficients through inverse quantization by the inverse quantization unit 108, inverse transformation by the inverse transformation unit 109 and reconstruction by the reconstruction unit 110, and is outputted to the prediction unit 104.
Patent Document 1: International Publication No. WO 2011/064926
Patent Document 2: Japanese Patent Publication No. 4146444
Patent Document 3: Japanese Patent Publication No. 4768779
In image encoding techniques such as MPEG-2 and MPEG-4, the quantization step size is controlled on a MB basis. However, the image to be encoded is an image regardless of boundary of the MB. Accordingly, in the MB located at the boundary of an object present in the image, a complex region and a simple region may be mixed. When setting a smaller quantization step size in the MB located at the boundary of the object, the code amount of the complex region increases and the compression ratio decreases. Conversely, when setting a larger quantization step size in the MB, the image quality degradation of the simple region may be significant.
For example, FIG. 2 is a diagram showing an original image before encoding, and FIG. 3 is a diagram showing an image after encoding. In the encoding with reference to FIGS. 2 and 3, the quantization is performed with a larger quantization step size when a variation in pixel values is large in the MB, and the quantization is performed with a smaller quantization step size when a variation in pixel values is small in the MB. When viewing the image after encoding, degradation of a leaf portion is not significant, but a block noise due to an encoding may be checked at a boundary portion between sky and leaves (portion inside a dashed ellipse).